Agent-level stream event labels and emit helpers.
A thin wrapper over ::hot::stream (the engine-level emission
primitive). This namespace defines the stable agent-level event
labels (<agent>:reply:start / :delta / :end,
<agent>:memory:forget:start / :end, …) and the helpers that
emit them via ::hot::stream/data underneath.
Concrete agents and the harness's own chat-turn reach for these
helpers so that custom UIs can subscribe to a stable, agent-scoped
event surface while provider-level streaming changes underneath.
Values
MEMORY_COMPACT_END
MEMORY_COMPACT_END: Str "ai:agent:memory:compact:end"
MEMORY_COMPACT_ERROR
MEMORY_COMPACT_ERROR: Str "ai:agent:memory:compact:error"
MEMORY_COMPACT_START
MEMORY_COMPACT_START: Str "ai:agent:memory:compact:start"
MEMORY_EXPORT_END
MEMORY_EXPORT_END: Str "ai:agent:memory:export:end"
MEMORY_EXPORT_ERROR
MEMORY_EXPORT_ERROR: Str "ai:agent:memory:export:error"
MEMORY_EXPORT_START
MEMORY_EXPORT_START: Str "ai:agent:memory:export:start"
MEMORY_FORGET_END
MEMORY_FORGET_END: Str "ai:agent:memory:forget:end"
MEMORY_FORGET_ERROR
MEMORY_FORGET_ERROR: Str "ai:agent:memory:forget:error"
MEMORY_FORGET_START
MEMORY_FORGET_START: Str "ai:agent:memory:forget:start"
REPLY_DELTA
REPLY_DELTA: Str "ai:agent:reply:delta"
REPLY_END
REPLY_END: Str "ai:agent:reply:end"
REPLY_ERROR
REPLY_ERROR: Str "ai:agent:reply:error"
REPLY_SOURCES
REPLY_SOURCES: Str "ai:agent:reply:sources"
REPLY_START
REPLY_START: Str "ai:agent:reply:start"
Functions
emit
fn (data-type: Str, payload: Any): Null
Emit a stream event, swallowing missing-stream-context errors.
Example
::ai::agent::stream/emit("team-agent:status", {state: "typing"})
emit-memory-end
fn (agent-name: Str, action: Str, payload: Map): Null
Emit <agent-name>:memory:<action>:end when a memory action finishes.
Returns null. Does nothing outside a stream context.
Example
::ai::agent::stream/emit-memory-end("team-agent", "forget", {session_id: "s1", deleted: 12})
emit-memory-error
fn (agent-name: Str, action: Str, payload: Map): Null
Emit <agent-name>:memory:<action>:error when a memory action fails.
Returns null. Does nothing outside a stream context.
Example
::ai::agent::stream/emit-memory-error("team-agent", "forget", {session_id: "s1", error: "store unavailable"})
emit-memory-start
fn (agent-name: Str, action: Str, payload: Map): Null
Emit <agent-name>:memory:<action>:start, where action is a word such
as forget, compact or export. Returns null. Does nothing outside
a stream context.
Example
::ai::agent::stream/emit-memory-start("team-agent", "forget", {session_id: "s1"})
emit-reply-delta
fn (agent-name: Str, payload: Map): Null
Emit <agent-name>:reply:delta with the next piece of reply text in
payload.delta. Returns null. Does nothing outside a stream context.
Example
::ai::agent::stream/emit-reply-delta("team-agent", {session_id: "s1", message_id: "m1", delta: "Hel"})
emit-reply-end
fn (agent-name: Str, payload: Map): Null
Emit <agent-name>:reply:end with the final reply in payload.text.
Returns null. Does nothing outside a stream context.
Example
::ai::agent::stream/emit-reply-end("team-agent", {session_id: "s1", message_id: "m1", text: "Hello."})
emit-reply-error
fn (agent-name: Str, payload: Map): Null
Emit <agent-name>:reply:error when a reply cannot finish. Returns
null. Does nothing outside a stream context.
Example
::ai::agent::stream/emit-reply-error("team-agent", {session_id: "s1", message_id: "m1", error: "provider timed out"})
emit-reply-sources
fn (agent-name: Str, payload: Map): Null
Emit <agent-name>:reply:sources so a client can show what a reply drew
on. Returns null. Does nothing outside a stream context.
Example
::ai::agent::stream/emit-reply-sources("team-agent", {session_id: "s1", message_id: "m1", sources: [{title: "Runbook"}]})
emit-reply-start
fn (agent-name: Str, payload: Map): Null
Emit <agent-name>:reply:start. Send it before the first delta. Returns
null. Does nothing outside a stream context.
Example
::ai::agent::stream/emit-reply-start("team-agent", {session_id: "s1", message_id: "m1"})
label
fn (agent-name: Str, topic: Str, verb: Str): Str
Build an agent-specific stream label, e.g. team-agent:reply:delta.
Example
::ai::agent::stream/label("team-agent", "reply", "delta") // "team-agent:reply:delta"