pipecrab-lm: the language-model interface.
[LanguageModel] is the swappable LM capability the conversation loop drives:
a [Conversation] in, generated text out incrementally — every
[TokenStream] item is a preemption point, so a barge-in
Interrupt stops the reply within a
single delta. Concrete engines stay behind it, so the pipeline never names
one.
[LmStage] adapts any [LanguageModel] into a pipeline
Stage: it tracks the running [Conversation]
(system prompt injected at construction), and on a final user
Transcript it appends the turn and streams a
generated reply back as agent transcripts — partials as deltas arrive, then a
final.
The chat-context types ([ChatRole], [Message], [Conversation]) are the
LM's own view of the dialogue, kept distinct from core's transcript
Role because the LM needs a
System role the transcript stream has no notion of. The
trait carries an optional grammar constraint but no
tool or dispatch concept — a dispatcher parses constrained output above this
layer.
Platform-neutral and wasm32-checkable: the concrete engines live elsewhere
(a native llama.cpp context, a browser engine in a Web Worker), each behind
this trait, so the interface itself carries no backend dependency and compiles
for both the host and wasm32-unknown-unknown.