Skip to content

Class: Engine

Defined in: aiui-lowering-pipeline/src/engine.ts:32

Constructors

Constructor

new Engine(settings?, now?): Engine

Defined in: aiui-lowering-pipeline/src/engine.ts:50

Parameters

settings?

Partial<IntentPipelineConfig> = {}

now?

() => number

Returns

Engine

Properties

armed

armed: boolean = false

Defined in: aiui-lowering-pipeline/src/engine.ts:35


events

events: IntentEvent[] = []

Defined in: aiui-lowering-pipeline/src/engine.ts:34


mode

mode: Mode = "ink"

Defined in: aiui-lowering-pipeline/src/engine.ts:36


paused

paused: boolean = false

Defined in: aiui-lowering-pipeline/src/engine.ts:40

Collection is paused (the turn-pause/turn-resume bracket is open).


settings

readonly settings: IntentPipelineConfig

Defined in: aiui-lowering-pipeline/src/engine.ts:33


talking

talking: boolean = false

Defined in: aiui-lowering-pipeline/src/engine.ts:37


threadOpen

threadOpen: boolean = false

Defined in: aiui-lowering-pipeline/src/engine.ts:38

Methods

appSelection()

appSelection(selection): boolean

Defined in: aiui-lowering-pipeline/src/engine.ts:259

Record an app selection — a positional stream event like text and shots. EVERY add mints a fresh sel_N marker: its own chip, its own item (owner, 2026-07-20). The old refinement rule — reuse the last marker while nothing contentful intervened, so an ambient watcher could track a drag on one chip — is retired: no watcher ever shipped, and its only observable effect was squashing consecutive DELIBERATE adds (select A, add; select B, add — nothing spoken between) into one latest-wins chip. Should a live watcher return, refinement wants an explicit flag on the call, not a stream-shape heuristic.

With no thread open: an armed engine opens one (the extension panel's pull model — "add selection" is a deliberate act, as contentful as a contribution). Unarmed remains a no-op.

Parameters

selection

AppSelection

Returns

boolean


appSelectionDrop()

appSelectionDrop(marker?): boolean

Defined in: aiui-lowering-pipeline/src/engine.ts:281

Retract one app selection (a chip's ✕ / a cleared watcher): the given marker, or — when none is passed — the turn's most recent still-carried selection. Returns false (emitting nothing) when there is no thread or nothing left to retract.

Parameters

marker?

string

Returns

boolean


codeSelection()

codeSelection(selection): string | undefined

Defined in: aiui-lowering-pipeline/src/engine.ts:229

Ingest a code selection contributed from ANOTHER view of the session (the reader's "Add to prompt →"). Same lifecycle as contribute — opens the thread if armed, no-op when not — but emits the structured code-selection event instead of pre-rendered text: how it reads in the prompt is composeIntent's decision, made at lowering time. Returns the assigned marker (code_N — the chip's retraction handle), or undefined.

Parameters

selection

CodeSelection

Returns

string | undefined


contribute()

contribute(text): number | undefined

Defined in: aiui-lowering-pipeline/src/engine.ts:186

Ingest text contributed from ANOTHER view of the session (a code selection from the reader, over the session bus) as content in the current turn. Opens the thread if armed, then emits it as a transcript-final so it composes into the prompt exactly like spoken text and shows in the preview. No-op when not armed — a contribution needs an armed turn to join. Returns the segment number it was recorded under, or undefined.

Parameters

text

string

Returns

number | undefined


dropCodeSelection()

dropCodeSelection(marker): void

Defined in: aiui-lowering-pipeline/src/engine.ts:240

Retract a code selection from the turn (the chip's ✕ — see the event doc).

Parameters

marker

string

Returns

void


dropShot()

dropShot(marker): void

Defined in: aiui-lowering-pipeline/src/engine.ts:539

Retract a shot from the turn (see the shot-drop event's doc).

Parameters

marker

string

Returns

void


ingestLinter()

ingestLinter(event): void

Defined in: aiui-lowering-pipeline/src/engine.ts:75

Merge a server-produced ADVISORY event — the linter's note / tool call / result / turn-complete — into the stream. Advisory only: composeIntent skips every linter-* kind, so ingestion changes the preview's chips and the trace — never the prompt. One that arrives after its thread closed is dropped (nothing to advise on anymore).

Parameters

event

{ at: number; segment?: number; text: string; type: "linter-note"; } | { args: Record<string, unknown>; at: number; tool: string; type: "linter-tool-call"; } | { at: number; ok: boolean; summary: string; tool: string; type: "linter-tool-result"; } | { at: number; segment?: number; type: "linter-turn-complete"; }

Returns

void


inkCleared()

inkCleared(auto, reason?): void

Defined in: aiui-lowering-pipeline/src/engine.ts:440

Parameters

auto

boolean

reason?

"navigation"

Returns

void


navigation(from, to, kind?, tab?): boolean

Defined in: aiui-lowering-pipeline/src/engine.ts:451

Record a same-document navigation (the intent client's navigation watcher). A navigation is context riding a turn, never a turn opener — the app-selection rule — so this is a no-op without an open thread. Returns whether an event was recorded.

Parameters

from

string

to

string

kind?

"replace" | "push" | "traverse" | "reload" | "hash"

tab?

TabRecord

The destination tab's full record, when the watcher gathered one.

Returns

boolean


onEvent()

onEvent(listener): () => void

Defined in: aiui-lowering-pipeline/src/engine.ts:58

Subscribe to every emitted event. Returns an unsubscribe (hosts whose panels outlive engines — the side panel — must detach; a host whose listeners share the page's lifetime may ignore it).

Parameters

listener

EngineListener

Returns

() => void


openTurn()

openTurn(): boolean

Defined in: aiui-lowering-pipeline/src/engine.ts:126

EXPLICITLY open a turn — the side panel's ⌘B (§13.6: a host where nothing opens implicitly; an implicit-turn host never calls this — its turns open on the first contentful act). No-op unless armed; no-op when a thread is already open. Returns whether a thread is open after the call.

Returns

boolean


replaceSegment()

replaceSegment(segment, text, words?): void

Defined in: aiui-lowering-pipeline/src/engine.ts:207

Replace a segment's transcript WHOLESALE (see the segment-replace event's doc): the panel's segment editor speaks this after the user fixes bad STT or pastes text. words are the editor's best-effort re-timestamped word timings — they are what lets the compiler REFLOW anchored shots against the new text. No-op when not armed, like every content verb.

Parameters

segment

number

text

string

words?

TranscriptWord[]

Returns

void


replay()

replay(events, state?): void

Defined in: aiui-lowering-pipeline/src/engine.ts:553

Rehydrate the stream from a recovered turn (HMR/reload turn recovery — the intent client's reload path). Replays each event through the current listeners so UI surfaces (preview, HUD) rebuild and the modality re-opens its socket, but WITHOUT re-stamping timestamps or arming idle timers (these events already happened). Restores the id counters from the log so new segments/shots can't collide with recovered ones, and leaves the engine armed with the given thread state. Talking is never resumed (the recording died with the page).

Parameters

events

IntentEvent[]

state?
mode?

Mode

threadOpen

boolean

Returns

void


send()

send(options?): void

Defined in: aiui-lowering-pipeline/src/engine.ts:333

Parameters

options?
keepArmed?

boolean

Returns

void


setArmed()

setArmed(on): void

Defined in: aiui-lowering-pipeline/src/engine.ts:103

Parameters

on

boolean

Returns

void


setMode()

setMode(mode): void

Defined in: aiui-lowering-pipeline/src/engine.ts:134

Parameters

mode

Mode

Returns

void


setPaused()

setPaused(on): void

Defined in: aiui-lowering-pipeline/src/engine.ts:325

Bracket a collection pause in the stream (the client's ⏸ / b — see the turn-pause event's doc). The GATING lives in the client's mode machine (available reads the sink); this records the bracket so the trace shows the gap. Reason-free by decision (owner, 2026-07-30). No-op without an open thread; a thread may CLOSE while paused — closeThread resets the flag silently (the close is the outer bracket, no turn-resume rides a dying thread).

Parameters

on

boolean

Returns

void


shotDone()

shotDone(rect, components, thumb?, path?, viewport?, takenAt?, share?, origin?): string

Defined in: aiui-lowering-pipeline/src/engine.ts:504

Parameters

rect

Rect

components

LocatedComponent[]

thumb?

string

path?

string

viewport?

boolean

takenAt?

number

share?

ShotShare

Set by the share's sampler; absent for a deliberate S / D-drag.

origin?

"paste"

"paste" when the pixels came from the clipboard, not the screen.

Returns

string


stepOut()

stepOut(): void

Defined in: aiui-lowering-pipeline/src/engine.ts:143

Esc, one level at a time: tweak → ink, ink+thread → cancel, → disarm.

Returns

void


strokeDone()

strokeDone(points, bounds): void

Defined in: aiui-lowering-pipeline/src/engine.ts:435

Parameters

points

number

bounds

Rect

Returns

void


tabSwitch()

tabSwitch(from, to, fromTab?, toTab?, tab?): boolean

Defined in: aiui-lowering-pipeline/src/engine.ts:480

Record a tab boundary — the user looked at a different tab mid-turn. A sibling of navigation (same rule: context riding a turn, a no-op without an open thread), but its own event so the lowering can say "you switched tabs" and carry the two tab identities. Returns whether an event was recorded.

Parameters

from

string

to

string

fromTab?

number

toTab?

number

tab?

TabRecord

The destination tab's full record, when the host gathered one.

Returns

boolean


talkEnd()

talkEnd(): void

Defined in: aiui-lowering-pipeline/src/engine.ts:394

Returns

void


talkStart()

talkStart(): number | undefined

Defined in: aiui-lowering-pipeline/src/engine.ts:382

Returns

number | undefined


transcriptDelta()

transcriptDelta(segment, text): void

Defined in: aiui-lowering-pipeline/src/engine.ts:408

Parameters

segment

number

text

string

Returns

void


transcriptFinal()

transcriptFinal(segment, text, latencyMs, model, words?): void

Defined in: aiui-lowering-pipeline/src/engine.ts:412

Parameters

segment

number

text

string

latencyMs

number

model

string

words?

TranscriptWord[]

Returns

void