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, 451 to 500 of 833

SessionStopInput type # line 15598

Added in 2.1.326

The input of session.stop: what the person's Stop found.

The engine's record: a hook observes, and next(e) passes it on.

  export type SessionStopInput = {
      /**
       * True where a turn of the main conversation was under way (at the terminal,
       * also a command the person waits on); a prompt not yet started reads false.
       */
      isTurnRunning: boolean;
  };

SessionStopResult type # line 15610

Added in 2.1.326

What a session.stop hook returns and what next(e) resolves to: { isTurnRunning }, echoed by core; a hook's own value changes nothing.

  export type SessionStopResult = {
      isTurnRunning: boolean;
  };

SessionUsage type # line 15622

Added in 2.1.267 · changed in 2.1.268, 2.1.280

What $.session.usage() answers: when the session began, the context window's fill, the account's rate-limit windows and the session's cost.

The status line's figures. One the engine does not have is left out, never zeroed: rateLimits is empty off a subscription, cost absent where the host keeps no ledger.

29 lines
  export type SessionUsage = {
      /**
       * When the session these figures count from began, in `$.clock.now()`'s
       * milliseconds: its launch, or for a resumed session its first launch.
       *
       * So what happened while a resumed or continued session was away still
       * counts as its own; `/clear` starts it over at that moment. The line the
       * engine's diff panel draws between this session's edits and earlier ones.
       *
       * @example
       * const isOlder = stat.mtimeMs < (await $.session.usage()).startedAt
       */
      startedAt: number;
      /**
       * The live context window: the status line's `context_window` figures.
       */
      context: SessionContextUsage;
      /**
       * The rate-limit windows the last API response reported (`five_hour`,
       * `seven_day`, a gateway's `spend_limit`); empty when none has a reading.
       */
      rateLimits: SessionRateLimit[];
      /**
       * What the session has cost so far, as /cost totals it, every mod's answered
       * `$.model` calls included; absent only where the host keeps no cost ledger
       * (the CLI always has one). An estimate, not the bill (SessionCost).
       */
      cost?: SessionCost;
  };

SessionUsageArgs type # line 15656

Added in 2.1.271

What $.session.usage(args) takes: nothing for the status line's figures alone; breakdown to have the window broken down as /context breaks it.

18 lines
  export type SessionUsageArgs = {
      /**
       * Asks for `context.breakdown` and says how it is counted
       * (ContextBreakdownDetail); absent, none is computed and the call is free.
       *
       * `full` sends one token-count request per tool and memory file, as
       * /context does; `summary` estimates locally and sends none.
       */
      breakdown?: ContextBreakdownDetail;
      /**
       * The width the breakdown's grid will be drawn in, in terminal columns;
       * absent, the full-width grid. Read only with `breakdown`.
       *
       * Under 80 the grid is the narrow one /context draws there, 5 wide. A thin
       * client's breakdown is the remote workspace's, whose grid ignores this.
       */
      columns?: number;
  };

SessionVersion type # line 15683

Added in 2.1.281

What $.session.version() answers: the version of the engine the session runs on, the release that version is built from, and when it was built.

The three are what the engine's own analytics rows carry as version, version_base and build_time, so a row a plugin sends and a row the engine sends from the same binary agree.

21 lines
  export type SessionVersion = {
      /**
       * The engine's full version, as `claude --version` prints it.
       *
       * A release's is `2.1.280`; a development build's adds the build's date,
       * time and commit (`2.1.280-dev.20260920.t101500.sha1a2b3c4`).
       */
      version: string;
      /**
       * The release the version is built from, its semantic core and channel:
       * `2.1.280` for that release, `2.1.280-dev` for a development build of it.
       *
       * Absent when the version is not spelled as a release.
       */
      base?: string;
      /**
       * When the binary was built, an ISO 8601 timestamp
       * (`2026-09-20T10:15:00Z`). Absent in a run from source that stamps none.
       */
      builtAt?: string;
  };

Settings type # line 15713

Added in 2.1.267 · changed in 2.1.268

What $.settings.read answers: an object keyed as a settings.json is (permissions, env, hooks, model, enabledPlugins, ...).

Each key is as https://code.claude.com/docs/en/settings documents it and https://json.schemastore.org/claude-code-settings.json types it. A snapshot in plain data: a write to it changes nothing the engine reads.

  export type Settings = Readonly<Record<string, unknown>>;

SettingsKeyRead type # line 15719

Added in 2.1.304

A read of one key: the key, and optionally the one source asked. It is the read of the object, projected: no event of its own.

  type SettingsKeyRead = {
      key: string;
      source?: SettingsSource;
  };

SettingsLayer type # line 15728

Added in 2.1.304

One layer a settings read is made of: what one source holds, as that source loads. The engine's merge is a fold over the layers.

  type SettingsLayer = {
      /**
       * Pinned: whose settings these are. `policy` is the managed settings,
       * every managed tier merged; a matcher cannot narrow on it.
       */
      source: SettingsLayerSource;
      /**
       * As a person or an administrator wrote them, so a value may be of any
       * type.
       */
      settings: Settings;
  };

SettingsLayerSource type # line 15745

Added in 2.1.304

Whose settings one layer of a read holds: a settings source, or plugin, the base the enabled plugins' own settings make, beneath user.

  type SettingsLayerSource = 'plugin' | SettingsSource;

SettingsObjectRead type # line 15751

Added in 2.1.304

A read of a settings object: the settings merged over every source, or the one source asked. It names no key.

  type SettingsObjectRead = {
      source?: SettingsSource;
      key?: undefined;
  };

SettingsReadArgs type # line 15760

Added in 2.1.267 · changed in 2.1.268, 2.1.304

What a settings.read call carries to the host: the one source asked, or none for the settings merged over every source.

  export type SettingsReadArgs = {
      /**
       * The one source read, as loaded; absent, the settings merged over every
       * source, as the engine runs under them.
       */
      source?: SettingsSource;
      /**
       * The engine's to fill, for the event (SettingsReadInput): what a call
       * passes here is replaced.
       */
      layers?: readonly SettingsLayer[];
  };

SettingsReadInput type # line 15781

Added in 2.1.304

The event settings.read as a hook receives it: what was asked, and the layers the answer is made of. One event, one granularity: the whole read.

A hook awaits next(e) and answers the settings object rewritten; the law it keeps is that its answer is a function of layers and of what next gave, so the same read gives the same answer.

16 lines
  type SettingsReadInput = {
      /**
       * Present for a read of one source, as loaded: its one layer.
       *
       * Pinned: changed, the hook fails and is skipped; left out, kept.
       */
      source?: SettingsSource;
      /**
       * What each source holds, lowest precedence first; a source with no
       * settings, or that the engine bars from the read, is left out.
       *
       * The engine's: whatever is passed down in their place, the same ones
       * reach the hooks beneath.
       */
      layers: readonly SettingsLayer[];
  };

SettingsReadOverloads type # line 15802

Added in 2.1.304

$.settings.read by what it is asked: a key resolves to that key's value, anything else to a settings object.

  type SettingsReadOverloads = {
      (args: SettingsKeyRead): Promise<unknown>;
      (args?: SettingsObjectRead): Promise<Settings>;
  };

SettingsSource type # line 15816

Added in 2.1.267 · changed in 2.1.268

One source of settings by the name a plugin gives it, lowest precedence first; the engine's own name is the same word with Settings appended.

user is ~/.claude/settings.json, project .claude/settings.json, local .claude/settings.local.json, flag what --settings and the SDK's inline settings carry, and policy the managed settings, every managed tier merged.

  export type SettingsSource = 'user' | 'project' | 'local' | 'flag' | 'policy';

SetupHookInput type # line 15818

Added in 2.1.265

  type SetupHookInput = BaseHookInput & {
      hook_event_name: 'Setup';
      trigger: 'init' | 'maintenance';
  };

ShaderProps type # line 15867

Added in 2.1.326

The props of Shader, a scene desktop plays on the GPU: the shader file module names, fed values, over one Svg child, shown alone on mobile.

It draws in a Backdrop alone, one at most, at the root or in a Box. Anywhere else, or over anything but one Svg, the tree is refused. The file is TypeScript against 'claude-code/shader' (declared below), never GLSL. The engine reads it at load and never runs it: it sends the app a checked form, which the app feeds the time and the person's pointers itself. None of that comes back to the mod, save a click on the bare backdrop (ui.pointer).

The Svg shows alone on an app that plays no shaders, under Reduce Motion, when the shader fails, flashes or runs too slowly, and when the engine refuses the file or a prop. A hook cannot tell which the person got, so draw the Svg as a finished scene. claude plugin validate lists the file with its cost, or names the line it refuses.

The Svg can be another mod's scene (await next(e)) where that is a bare Svg. A hook may keep a Shader next(e) handed it and change its values, not its module; otherwise the hook fails and is skipped.

// hooks/beam.ts holds `values({ x: [0, 1], y: [0, 1], clicks: [0, 9] })`
let aim = { x: 0.5, y: 0.5, clicks: 0 }
on("session.start", async ($, e, next) => {
  await $.theme.set({ backdrop: { scene: "stage" } })
  return next(e)
})
on("ui.render", { component: "Backdrop" }, ($, e, next) => {
  if (e.surface !== "desktop" && e.surface !== "mobile") return next(e)
  if (e.props.plugin !== "spotlight") return next(e)
  const { Shader, Svg } = $.ui.resolve(e)
  return (
    <Shader module="./beam.ts" values={aim}>
      <Svg source={STAGE_SVG} alt="An empty stage" />
    </Shader>
  )
})
on("ui.pointer", ($, e, next) => {
  aim = { x: e.x, y: 1 - e.y, clicks: aim.clicks + 1 }
  $.ui.invalidate("ui.render")
  return next(e)
})
23 lines
  export type ShaderProps = {
      /**
       * The shader file's path, a string literal relative to this file, written
       * in the `Shader` element itself: `module="./beam.ts"`.
       *
       * Read off the source, as a `Client`'s is. A variable, a renamed `Shader`,
       * a path outside the plugin or no such file leaves the Svg; the mod loads.
       */
      module: string;
      /**
       * Finite numbers under the names the file's `values({ ... })` declares, 8 at
       * most, each held to its range; one left out is its low end. Another name is
       * refused.
       *
       * A redraw that changes only these keeps the shader running and eases it to
       * them. The app rounds each to 10 bits of its range, and clears the shader's
       * buffers once many have changed. So send state, never a stream on a timer:
       * what fades, moves or piles up belongs in a `buffer`, stepped with `dt`.
       */
      values?: {
          readonly [name: string]: number;
      };
  };

Shaped type # line 15901

Added in 2.1.281

A value kept with a shape tag, as an atom given { shape } keeps it: a reload whose code names another tag reads the value as absent.

Declare the key as Shaped<T> in PluginState when its atom names a shape; the atom reads and takes T.

interface PluginState { board: { cells: Shaped<Cell[]> } }
  export type Shaped<T> = {
      shape: string;
      value: T;
  };

ShapedValue type # line 15910

Added in 2.1.281

What an atom given a shape reads and takes for a key declared Shaped<T>: T; never for a key declared otherwise, so that atom does not compile.

  export type ShapedValue<V> = V extends Shaped<infer T> ? T : never;

SiteScroll type # line 15916

Added in 2.1.267 · changed in 2.1.268

Where a site's window sits over the tree a hook drew in it (a pane's body, the band): the engine's to move (the person scrolls), the plugin's to read.

16 lines
  export type SiteScroll = {
      /**
       * The first row of the tree the window showed when the hook was asked; 0
       * at the top. Read-only.
       *
       * A move through `ui.scroll` (the person's, `$.ui.scroll`) asks again. On
       * the terminal the engine's own does not (an end followed, a clamp, a held
       * element kept in view): the next ask reads where the window stands then.
       */
      offset: number;
      /**
       * How many rows of the tree the window may show at once: the rows the
       * surface gave the body, whatever the tree's own height. Read-only.
       */
      bodyRows: number;
  };

SiteView type # line 15941

Added in 2.1.271

Which transcript the person has on screen where a site draws: the main conversation's, or one agent's, opened from the tasks list.

A site reads it: a switch re-runs the site's hooks with the new view, the site itself staying where it is. $.ui.view takes the same shape to ask for a switch, which only the person's own input brings about.

  export type SiteView = {
      /**
       * The agent whose transcript is in view: the `id` `$.agent.list()` gives
       * it, the `agentId` its `turn.step` and `tool.call` events carry.
       *
       * Absent while the main conversation is in view. Read-only on a site.
       */
      agentId?: string;
  };

SkillFrontmatter interface # line 15959

Added in 2.1.299

What a skill's file declares above its text, parsed and JSON-safe: each key as YAML reads it, none respelled, each value whatever JSON holds.

Plain data within its bounds (32 levels, 20,000 values, 100,000 characters): a block past them is handed as {}. An interface, since a JSON type that is one recursive alias fails where e is passed to next.

  export interface SkillFrontmatter {
      readonly [key: string]: SkillFrontmatterValue;
  }

SkillFrontmatterList interface # line 15966

Added in 2.1.299

A YAML sequence in a skill's frontmatter, as JSON holds it.

  export interface SkillFrontmatterList extends ReadonlyArray<SkillFrontmatterValue> {
  }

SkillFrontmatterValue type # line 15976

Added in 2.1.299

One value in a skill's frontmatter: what JSON holds, and assignable to and from JsonValue.

A date is the text its author wrote. What JSON cannot hold (NaN, an infinity) is null.

  export type SkillFrontmatterValue = null | boolean | number | string | SkillFrontmatterList | SkillFrontmatter;

SkillPromptArgs type # line 15985

Added in 2.1.299

skill.prompt's input as a call takes it: frontmatter and source may be left out, as a caller written before the event carried them does.

Left out, they read {} and built-in: a skill with no file. What a call states is the caller's word, which the hooks it reaches are handed.

  export type SkillPromptArgs = Omit<SkillPromptInput, 'frontmatter' | 'source'> & Partial<Pick<SkillPromptInput, 'frontmatter' | 'source'>>;

SkillPromptInput type # line 15995

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

The input of skill.prompt: one skill's prompt, at the moment the engine expanded it for the model.

Typed as /name, run by the Skill tool, or preloaded into a subagent (named there as its agent wrote it). text and frontmatter are a hook's to rewrite for the hooks beneath it; the rest is pinned.

48 lines
  export type SkillPromptInput = {
      /**
       * Which skill (`commit`); the key a matcher narrows on.
       */
      skill: string;
      /**
       * The prompt's text as the skill computed it (its text blocks, joined).
       */
      text: string;
      /**
       * What the skill's file declares above its text, as its author wrote it: keys
       * as YAML reads them, a remote author's strings scrubbed.
       *
       * No key `__proto__`, `constructor` or `prototype` (left out of a file, the
       * last two named in `frontmatterProblem`). Not the effective grants: a plugin
       * manifest or managed setting may differ; a call's are read at `tool.check`.
       */
      frontmatter: SkillFrontmatter;
      /**
       * Why the file's frontmatter was left out (`{}`), or a key of it: prose for
       * a person, not to match on; absent if handed whole or none exists.
       *
       * The engine refuses nothing for it: a hook that decides on frontmatter
       * is the one to refuse a skill whose problem is set.
       */
      frontmatterProblem?: string;
      /**
       * Whose words these are, in `SkillSource`'s words.
       *
       * A `projectSettings` skill's words are its repository's, wherever its
       * checkout is read (another machine's too), an `mcp` skill's its server's:
       * as loaded, vouched for by none. A call's is the caller's word.
       */
      source: SkillSource;
      /**
       * An installed plugin's name, when the skill comes from one.
       */
      pluginName?: string;
      /**
       * Where the file it was loaded from is, as an absolute path: a skill's
       * SKILL.md, or a command's own `.md` file.
       *
       * As the loader joined it, no link resolved; on a call, the caller's word.
       * Absent with no file on this machine: a built-in, an MCP server's, a
       * plugin command written inline in its manifest.
       */
      path?: string;
  };

SkillPromptResult type # line 16048

In the first published surface (2.1.259)

What a skill.prompt hook returns: the text the model reads for that skill.

  export type SkillPromptResult = {
      text: string;
  };

SkillSource type # line 16060

Added in 2.1.299

Whose words a skill is, in the engine's own words: the settings tier whose skills folder holds it, or what else provides it.

built-in ships in the build, which holds no file: its frontmatter is {}. plugin comes with a plugin, mcp from a server, syncedSkills from the account. The list is open: a newer source is a word of its own.

  export type SkillSource = 'userSettings' | 'projectSettings' | 'policySettings' | 'plugin' | 'built-in' | 'mcp' | 'syncedSkills' | (string & {});

SleepOptions type # line 16065

In the first published surface (2.1.259)

Options of $.clock.sleep.

  export type SleepOptions = {
      /**
       * Aborting it rejects the sleep at once.
       */
      signal?: AbortSignal;
  };

SourceValues type # line 16076

Added in 2.1.281

The values derive's function receives for its sources, in their order: an atom's or a derived value's own, a plain reference's or undefined.

  export type SourceValues<S extends readonly unknown[]> = {
      [I in keyof S]: S[I] extends Atom<infer V> ? V : S[I] extends Derived<infer V> ? V : S[I] extends StateName<infer P, infer K> ? P extends keyof PluginState & string ? K extends keyof PluginState[P] & string ? StateValue<P, K> | undefined : unknown : unknown : unknown;
  };

Space type # line 16088

Added in 2.1.299

A Box's spacing: a number of character cells, the same on every surface, or a step name that each surface sizes its own way. The terminal and VS Code draw a step as cells: across, xs and sm 1, md 2, lg 3, xl 4; down, xs and sm 0, md and lg 1, xl 2. Desktop and the phones each use their own spacing scale, so there a step can be larger or smaller than those cells.

  export type Space = number | 'xs' | 'sm' | 'md' | 'lg' | 'xl';

SpeakOptions type # line 16093

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

Options of $.audio.speak.

22 lines
  export type SpeakOptions = {
      /**
       * The system voice's exact name as the platform lists it (`Samantha`, or the
       * name of a voice you installed). Absent: the synthesizer's default voice.
       */
      voice?: string;
      /**
       * Aborting it skips the utterance while it is queued, or cuts it off while
       * it is spoken; either way the promise rejects at once.
       *
       * It rejects with an Error whose message is the abort reason's text and
       * whose name depends on the host: read `signal.aborted` to tell. Already
       * aborted, it rejects so and nothing is queued. A hook on `audio.speak`
       * has it as `next.signal`, and one that answers the call settles it.
       *
       * @example
       * // another hook calls stop.abort() when the person starts talking
       * try { await $.audio.speak(text, { signal: stop.signal }) }
       * catch (error) { if (!stop.signal.aborted) throw error }
       */
      signal?: AbortSignal;
  };

SpeakRequest type # line 16120

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

The argument of $.audio.speak(text, options) as the event carries it: the signal does not cross.

  type SpeakRequest = {
      /**
       * What to say, as plain text: its first 4096 characters are spoken.
       */
      text: string;
      /**
       * The system voice's exact name (SpeakOptions); absent, the default.
       */
      voice?: SpeakOptions['voice'];
  };

SpeakResult type # line 16134

In the first published surface (2.1.259)

What $.audio.speak resolves with once the utterance has ended.

  export type SpeakResult = {
      /**
       * Which synthesizer spoke: `system`, the platform's own (`say` on macOS).
       */
      via: 'system';
  };

StarNext type # line 16149

In the first published surface (2.1.259) · changed in 2.1.265, 2.1.267, 2.1.268, 2.1.275, 2.1.328

next in a * hook: the set of events is open at runtime, so e is unknown until next.is(pattern, e) narrows it to events it knows.

The callable is an overload per known event (OrderedOverloads), then (e: unknown) => Promise<unknown> last: next(e) with e still unknown resolves to unknown.

14 lines
  export type StarNext = OrderedOverloads<EventName> & {
      (e: unknown): Promise<unknown>;
      /**
       * Continues this dispatch at a tier, as Next's `to` (a managed hook's):
       * `e` still unknown resolves to `unknown`.
       */
      readonly to: (e: unknown, tier: TargetTier) => Promise<unknown>;
      readonly signal: AbortSignal;
      readonly is: <M extends Pattern>(pattern: M, e: unknown) => e is Frozen<Args<Selected<M>>>;
      readonly event: EventName;
      readonly origin: NextOrigin;
      readonly trace: readonly TraceEntry<EventName, unknown, unknown>[];
      readonly budget: NextBudget;
  };

StateAddress type # line 16170

Added in 2.1.281

Which named value a $.state call is about, as it crosses to the host: the owning plugin, the key, and a family member's id.

The untyped form of a StateRef; identity, pinned on every next.

  export type StateAddress = {
      plugin: string;
      key: string;
      id?: string;
  };

StateDollar type # line 16180

Added in 2.1.281

What the state library's read and update take of $: its state noun, on which they make the calls a hook would make itself.

  export type StateDollar = Pick<CoreEngineInterface, 'state'>;

StateFamily type # line 16193

Added in 2.1.281

A key of PluginState that holds one value of type T per id (one per drawn row, per worker): its reference must carry id: string.

Only a marker in the registry; no value has this shape. $.state.get on a member answers T, and a reference to the family without an id does not compile.

interface PluginState { notes: { isOpen: StateFamily<boolean> } }
  export type StateFamily<T> = {
      readonly byId: T;
  };

StateGetEvent type # line 16204

Added in 2.1.281

e of state.get: one variant per value a contract declares, so a matcher on plugin and key narrows it; the untyped address while none does.

on("state.get", { plugin: "swarm" }, ($, e, next) => next(e))
  export type StateGetEvent = [DeclaredPair] extends [never] ? StateAddress : DeclaredEvents<DeclaredPair>['get'];

StateName type # line 16210

Added in 2.1.281

Which named value: the plugin that owns it and its key there, both literals where a contract declares the value.

  type StateName<P extends string = string, K extends string = string> = {
      readonly plugin: P;
      readonly key: K;
  };

StateRead type # line 16222

Added in 2.1.281

What $.state.get answers: the value and the version it stands at; a value never written is undefined at version 0.

The version goes up by one on every write that lands; hand it back as ifVersion to write only if nobody wrote in between.

  export type StateRead<T = unknown> = {
      value: T | undefined;
      version: number;
  };

StateRef type # line 16238

Added in 2.1.281

A typed reference to one named value: the owning plugin and the key, both literals, and for a StateFamily key the member's id.

Written once as a constant and passed to $.state.get and $.state.set; plugin and key must be literals in source so claude plugin validate lists what a module reads and writes. Only id may be computed.

const workers = { plugin: "swarm", key: "workers" } as const
  export type StateRef<P extends keyof PluginState & string, K extends keyof PluginState[P] & string> = StateName<P, K> & (PluginState[P][K] extends StateFamily<unknown> ? Readonly<Required<Pick<StateAddress, 'id'>>> : Readonly<Partial<Record<'id', undefined>>>);

StateSetEvent type # line 16250

Added in 2.1.281

e of state.set: one variant per value a contract declares, so a matcher on plugin and key narrows e.value; the untyped write while none does.

plugin, key and id are identity, pinned; value is a hook's to rewrite, which is how a plugin that does not own a value changes it.

on("state.set", DRIVE, ($, e, next) => next({ ...e, value: false }))
  export type StateSetEvent = [DeclaredPair] extends [never] ? StateWrite : DeclaredEvents<DeclaredPair>['set'];

StateSetOptions type # line 16256

Added in 2.1.281

The options of $.state.set: ifVersion makes the write conditional on the value still standing at that version (compare-and-set).

  export type StateSetOptions = {
      ifVersion?: number;
  };

StateSetResult type # line 16267

Added in 2.1.281

What $.state.set answers: whether the write landed, and the version the value stands at now (a landed write's own, a missed one's the current).

isSet is false only for a write given ifVersion that another write beat; nothing changed then, and a $.state.get reads what stands.

  export type StateSetResult = {
      isSet: true;
      version: number;
  } | {
      isSet: false;
      version: number;
  };

StateValue type # line 16279

Added in 2.1.281

The type of the value under key K of plugin P, as its contract declares it in PluginState; a StateFamily's member type for a family key.

  export type StateValue<P extends keyof PluginState & string, K extends keyof PluginState[P] & string> = PluginState[P][K] extends StateFamily<infer Member> ? Member : PluginState[P][K];

StateWrite type # line 16288

Added in 2.1.281

A $.state.set as it crosses to the host and as its hooks see it when no contract declares the value: the address, the value, and the condition.

previous is the host's, put on e ahead of every hook: what stood there when the write was raised.

  export type StateWrite = StateAddress & {
      value: unknown;
      previous?: unknown;
      ifVersion?: number;
  };

StopFailureHookInput type # line 16294

Added in 2.1.265

  type StopFailureHookInput = BaseHookInput & {
      hook_event_name: 'StopFailure';
      error: SDKAssistantMessageError;
      error_details?: string;
      last_assistant_message?: string;
  };

StopHookInput type # line 16301

Added in 2.1.265

16 lines
  type StopHookInput = BaseHookInput & {
      hook_event_name: 'Stop';
      stop_hook_active: boolean;
      /**
       * Text content of the last assistant message before stopping. Avoids the need to read and parse the transcript file.
       */
      last_assistant_message?: string;
      /**
       * In-flight background work (running/pending + backgrounded) registered in this session. Lets hooks distinguish "session is done" from "session is paused waiting for background work to wake it". Empty array when nothing is in flight.
       */
      background_tasks?: BackgroundTaskSummary[];
      /**
       * Session-scoped cron tasks (CronCreate, ScheduleWakeup, /loop) that will wake this session later. Empty array when none are scheduled.
       */
      session_crons?: SessionCronSummary[];
  };

StreamHook type # line 16329

Added in 2.1.269

The hook a streaming event takes: async function* ($, e, next) {}, yielding the event's chunks and returning its result.

return yield* next(e) passes; for await (const c of next(e)) yield f(c) transforms; yielding without next answers alone. A chunk yielded stays: a hook that fails mid-stream is left, the rest from beneath it.

on('turn.step', async function* ($, e, next) {
  const r = yield* next(e); return { ...r } })
  export type StreamHook<N extends StreamingEventName> = ($: EngineInterface, e: Frozen<Args<N>>, next: StreamNext<N>) => StreamHookBody<Chunk<N>, EventResult<N>>;

StreamHookBody type # line 16339

Added in 2.1.269

What a hook on a streaming event evaluates to: the async generator an async function* makes, yielding C and returning R or nothing.

Returning nothing lets its last next(e)'s result stand. A plain function is a type error here even when it returns next(e): the hook is the generator, not a function that hands one back.

  export type StreamHookBody<C, R> = AsyncGenerator<C, R | void> & {
      /**
       * Absent on a generator; present on `next(e)`, which is not a hook body.
       */
      readonly result?: never;
  };
Feedback