System prompt construction for the agent loop and channel subsystem.
These functions were originally in channels/mod.rs but live here to
break a circular dependency between the channels and agent modules.
Borrow-only Attributable holding an agent alias.
Used by entry points (loop_::run, process_message, cron dispatch)
that don’t construct a full Agent but still need to open an
attribution_span! carrying the agent’s role + alias.
Lightweight metadata for turn-level event emission.
Built at emission call sites from the turn’s borrows — not a cached duplicate.
The values are borrows from the turn mint site; the mint site stays the
single source of truth for the (channel, agent_alias, turn_id) triple.
Process a single message through the full agent (with tools, peripherals, memory).
Used by channels (Telegram, Discord, etc.) to enable hardware and tool use.
Structured-aware credential scrub for a JSON value bound for a human-facing
surface. Object entries whose key names a credential have their entire value
replaced with a marker, preserving the key. Every other string leaf still
runs through the text scrub_credentials so inline token=... patterns
inside unrelated fields are caught too. Serialize-then-scrub would corrupt
key names that merely contain a sensitive word (e.g. access_token), so this
walks the value instead. Same rendering-boundary contract as
scrub_credentials.