Skip to content

Function: composeIntent()

composeIntent(events, policy?, options?): ComposedIntent

Defined in: aiui-lowering-pipeline/src/compose.ts:49

Fold the current thread's events into the composed intent. Pure — the inspector re-runs it on every event, which makes the behavior directly observable while you interact (and trivially unit-testable).

Structured as a MULTI-PASS lowering (owner, 2026-07-14 — "as if you're a compiler engineer"), each pass a named function over an explicit IR:

  1. scan — one walk over the stream collecting every stream-wide fact later passes consult (StreamFacts): drops, talk windows, delta timelines, word timestamps, and segment REPLACEMENTS (latest-wins, respecting deletes — the segment editor's segment-replace).
  2. place — append items in stream order. A replaced segment's text is superseded IN PLACE: the item sits where the segment's first placer (its final, normally) sits, carrying the replacement text.
  3. corrections — the spoken-correction patches against the transcript-as-lines (unchanged semantics; replace policy only).
  4. interleave — the timestamp reflow: anchored items (shots by their capture gesture, selections by their add instant) move INSIDE their segment's text, split at word-timestamp offsets. Replacements reflow here for free: their re-timestamped words landed in StreamFacts.wordsBySegment during the scan.
  5. render — transcript + the lowered prompt body.

Correction semantics under replace: each correction rewrites the first remaining occurrence of its original text (ranges were lassoed against a live preview; original-text anchoring survives earlier rewrites better than absolute offsets). Under note, corrections append as instructions for the downstream lowering model instead.

Parameters

events

IntentEvent[]

policy?

"replace" | "note"

options?

ComposeOptions = {}

Returns

ComposedIntent